package com.pharmacy.pharmacy.controller;

import com.pharmacy.pharmacy.domain.Medicine;
import com.pharmacy.pharmacy.service.IMedicineService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

import java.util.List;

/**
 * 【】Controller
 * 
 * @author 
 * @date 2025-05-08
 */
@CrossOrigin
@RestController
@RequestMapping("/system/medicine")
public class MedicineController 
{
    @Autowired
    private IMedicineService medicineService;

    /**
     * 查询【】列表
     */
    @GetMapping("/list")
    public List<Medicine> list(Medicine medicine)
    {
        return medicineService.selectMedicineList(medicine);
    }

    /**
     * 获取【】详细信息
     */
    @GetMapping(value = "/{id}")
    public Medicine getInfo(@PathVariable("id") Long id)
    {
        return medicineService.selectMedicineById(id);
    }

    /**
     * 新增【】
     */
    @PostMapping
    public int add(@RequestBody Medicine medicine)
    {
        return medicineService.insertMedicine(medicine);
    }

    /**
     * 修改【】
     */
    @PutMapping
    public int edit(@RequestBody Medicine medicine)
    {
        return medicineService.updateMedicine(medicine);
    }

    /**
     * 删除【】
     */
    @DeleteMapping("/{ids}")
    public int remove(@PathVariable Long[] ids)
    {
        return medicineService.deleteMedicineByIds(ids);
    }
}
